package study.ct.com.tvwebviewapplication;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button toWebview = (Button) findViewById(R.id.toWebview);
         final EditText input = (EditText) findViewById(R.id.input);

        toWebview.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String value= String.valueOf(input.getText());
                if (value==null){
                    Toast.makeText(MainActivity.this,"请输入地址", Toast.LENGTH_SHORT).show();
                    return;
                }

                Intent intent = new Intent(MainActivity.this, WebViewActivity.class);
                intent.putExtra(WebViewActivity.UrlKey, value);
                startActivity(intent);
            }
        });

    }
}
